﻿namespace NetSurveillance.WebApp.DataServices
{
    public class ServiceResult
    {
        /// <summary>
        /// 执行成功否
        /// </summary>
        public bool ExecutedSuccess { get; set; }

        /// <summary>
        /// 影响条目
        /// </summary>
        public int EffectNumber { get; set; }

        /// <summary>
        /// 返回信息
        /// </summary>
        public string Message { get; set; }

        /// <summary>
        /// 返回一些处理的数据
        /// </summary>
        public dynamic ReturnObj { get; set; }

        public ServiceResult(){}

        /// <summary>
        /// 数据存储结果
        /// </summary>
        /// <param name="executeSucc">执行是否成功</param>
        /// <param name="message">返回消息</param>
        public ServiceResult(bool executeSucc, string message)
        {
            ExecutedSuccess = executeSucc;
            Message = message;
        }

        public static ServiceResult SuccessResult
        {
            get { return new ServiceResult { EffectNumber = 1, ExecutedSuccess = true }; }
        }

        public static ServiceResult UpdateFailureResult
        {
            get { return new ServiceResult {EffectNumber = 0, ExecutedSuccess = false, Message = "更新数据失败"}; }
        }
    }
}
